<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>信息推送历史</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/style_l.css"/>
<script type="text/javascript" src="${jspath }/jquery-1.4.4.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.blockUI.js"></script>
<script type="text/javascript" src="${jspath }/public.js"></script>
<script type="text/javascript" src="${jspath }/jquery.selectAll.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<script type="text/javascript" src="${jspath}/load_layer.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath}/jquery.alerts.css" />

<link rel="stylesheet" type="text/css"
	href="${webcontext}/css/validationEngine.jquery.css" />
<script src="${jspath}/jquery/validate/jquery.validationEngine.js"
	type="text/javascript"></script>
<script src="${jspath}/jquery/validate/jquery.validationEngine-zh.js"
	type="text/javascript"></script>
	<script type="text/javascript"
	src="${webcontext}/javascript/jquery/jquery.ui.draggable.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<style type="text/css">
.checkbox-li {
	display: inline-block;
	width: 100px;
}

#high10 {
	height: 10px;
}
</style>
<script type="text/javascript">
function confirmMsgPackageItem(){
	
	var isOk = false,isError = false;
	$("input[data='data']").each(function() {
		if (isNaN($(this).val())) {
			isOk = true;
		}
	});
	
	$("#dataTbody tr").each(function() {
		var $td = $(this).find("td:eq(1)");
		
		var $input = $(this).find("td:eq(2)").find("input:eq(1)");
		
		if($.trim($input.val()) != "" && $.trim($td.text()) != ""){
			if($input.val() > $td.text()){
				isError = true;
				jAlert("接收数量不能大于总数量","提示");
				return;
			}
		}
		//console.log($td.text() + "##" + $input.val());
	});
	
	if(isError){
		return;
	}
	
	
	if(isOk){
		jAlert("接收数量必须为数字！","提示");
		return;
	}
	
	$.ajax({
		url:'${webcontext}/crmdp/dealer/remind/comfirmMsgPackageItem',
		type:'post',
		data:$('#msgPackageForm').serialize(),
			success : function(data) {
				if(!data.result){
					jAlert(data.errorMsg);
				}else{
					jAlert("充值成功！","提示",function(){
						//parent.$('#txtpurchaseQuantity').val(parent.$('#txtpurchaseQuantity').val()+data.sumQuantity);
						parent.$('#lblpurchaseQuantity').text(parseInt(parent.$('#lblpurchaseQuantity').text())+parseInt(data.sumQuantity));
  					//当你在iframe页面关闭自身时
  					var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  					parent.layer.close(index); //再执行关闭  
					});
				}
        },
        error: function (msg) {
            alert(msg);
        }
	})
}
function returnRemind(){
	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(index); //再执行关闭  
}
</script> 
</head>
<body>
	 <form id='msgPackageForm' >
	 	<input type="hidden" value="${param.dealerNum}" >
	    <div id="dataTable" class="data_div">
		<table id="table" class="table " style="font-size: 85%">
			<thead>
				<tr>
					<th>短信包</th>
					<th>数量</th>
					<th>接收数量</th>
					<th>总条数</th>
				</tr>
			</thead>
			<tbody id="dataTbody">
				<core:forEach items="${msgPackageDtos}" var='msgPackageList' varStatus="status">
					<tr align="left">
	
						<td>${msgPackageList.msgPackageName }</td>
						<td>${msgPackageList.quantity }</td>
						<td>
						<input type="hidden" name="msgPackageDtos[${status.index}].logisticProcessId" value="${msgPackageList.logisticProcessId} "/>
						<input data="data" type="text" style="width:80px" name="msgPackageDtos[${status.index}].receiveQuantity"/></td>
						<td>${msgPackageList.sumQuantity }</td>
					</tr>
				</core:forEach>
			</tbody>
		</table>
		</div>
				    <div style="margin-left:100px">
				    <button type="button"  class="btn btn-success" onClick="confirmMsgPackageItem()">&nbsp;确定&nbsp;</button> &nbsp;&nbsp;&nbsp;&nbsp;
				   	<button type="button" class="btn btn-success" value="返回 " onclick="returnRemind()">&nbsp;返回&nbsp;</button>
				   	<div id='high10'></div>
				   	</div>
				   	</form>
	 
	</body>
	</html>